<!--http、https IP切换-->
<template>
  <div class="ne-jminput-box" v-show="formData[key].isshow">
    <el-form-item
      :label="component.attrName"
      :prop="key + '.value'"
      v-model="formData[key].value"
      :required="formData[key].required.split(',').includes('empty')"
    >
      <el-input
        placeholder="请输入IP地址"
        v-model="httpValue"
        class="input-with-select"
      >
      </el-input>
      <el-select
        v-model="httpPre"
        placeholder="请选择"
        class="ne-select-box select-box"
      >
        <el-option
          v-for="item in chooseHttp"
          :key="item.name"
          :label="item.name"
          :value="item.name"
        >
        </el-option>
      </el-select>
    </el-form-item>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "httpSelect",
  data() {
    return {
      httpValue: "",
      httpPre: "http://",
      chooseHttp: [
        {
          name: "http://",
        },
        {
          name: "https://",
        },
      ],
    };
  },
  props: {
    component: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
    },
    ruleData: {
      type: Object,
    },
    actionValue: {
      type: String,
      default: "",
    },
    span: {
      type: Number || String,
      default: 16,
    },
    config: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  computed: {
    ...mapState("user", ["user"]),
    key() {
      return this.component.pageTempStructId + "-" + this.component.attrId;
    },
  },
  watch: {
    httpValue: {
      handler(newVal, oldVal) {
        this.formData[this.key].value = newVal + this.httpPre;
      },
    },
    httpPre: {
      handler(newVal, oldVal) {
        this.formData[this.key].value = newVal + this.httpValue;
      },
    },
  },
  created() {},
};
</script>

<style lang="scss" scoped>
.ne-jminput-box {
  ::v-deep .el-form-item {
    position: relative;
  }
  ::v-deep .el-input__suffix {
    right: 0;
  }
  ::v-deep .el-select .el-input .el-select__caret {
    font-size: 0.12rem;
    position: relative;
    top: -0.01rem;
  }

  ::v-deep .select-box .el-input--suffix .el-input__inner {
    // padding-left: 0.07rem;
    text-align: left;
    // padding-right: 0.2rem;
    z-index: 9999;
    background-color: #f5f7fa;
  }
  .radio-mt {
    margin-top: 0.1rem;
  }
  .select-box {
    width: 1rem;
    padding: 0;
  }
  .ne-select-box {
    min-width: 44px;
    width: 0.8rem !important;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
  }
  ::v-deep .el-input__icon {
    line-height: normal !important;
  }
  ::v-deep .el-form-item__content {
    line-height: normal !important;
  }
  .input-with-select {
    padding-left: 0.7rem;
  }
}
</style>